const SERVERS = ['.zhongyingtougu.com', '2.zhongyingtougu.com'];
const Protocols = ['https', 'http'];
export var BASEURL = "http://stock.zhongyingtougu.com/v1";  	// http://api.integrity.com.cn
export var STOCKURL = "http://stock.zhongyingtougu.com";    	// 自有行情接口base url
export const WSURL = "http://stock.zhongyingtougu.com";    	// websocket base url
export var SITEURL = "http://api.zhongyingtougu.com";  		// http://hrhg.integrity.com.cn
export const BASEIMGURL = "http://ogvk6eo7a.bkt.clouddn.com";  	// "http://ogvk6eo7a.bkt.clouddn.com";

export var APISURL = "https://qy.zhongyingtougu.com/api/v1";	// CMS api base url


export var USERURL = "http://api.zhongyingtougu.com";			// UC接口base url

//短信
export const SIGNUPSMS = "signup";
export const SIGNINSMS = "signin";
export const CHANGEPWDSMS = "change/pwd";
export const CHANGEMOBILESMS = "bind/mobile";


export const TOGGLE_STATE = {
  "EXPANDED": "EXPANDED",
  "COLLAPSED": "COLLAPSED"
};

export const apiServer = {
	resetServer: function(){
		let current = (window.currentServerIndex) ? window.currentServerIndex : 0
		current = 1 - current
		window.currentServerIndex = current
		console.log("switch to server", SERVERS[current])
		BASEURL = Protocols[current] + "://stock" + SERVERS[current] + "/v1";  	// http://api.integrity.com.cn
		STOCKURL = Protocols[current] + "://stock" + SERVERS[current];    	// 自有行情接口base url
		SITEURL = Protocols[current] + "://api" + SERVERS[current];  		// http://hrhg.integrity.com.cn
		APISURL = Protocols[current] + "://qy" + SERVERS[current] + "/api/v1";	// CMS api base url
		USERURL = Protocols[current] + "://api" + SERVERS[current];			// UC接口base url
	},
	checkReload: function(url){
		let server = SERVERS[(window.currentServerIndex) ? window.currentServerIndex : 0]
		if (url.indexOf(server) >= 0) {
			return false
		} else {
			return true
		}
	},
	getNewURL: function(url) {
		let current = (window.currentServerIndex) ? window.currentServerIndex : 0
		url = url.replace(SERVERS[1 - current], SERVERS[current]).replace(Protocols[1 - current], Protocols[current])
		return url
	}
};
